package {
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	public class tf1 extends Sprite{
		private var dur:Number=30;
		
		public function tf1(){
			init();
		}
		
		private function init(){
			var btn1:Sprite = new CircleSprite(30);
			var btn2:Sprite = new CircleSprite(30);
			var btn3:Sprite = new CircleSprite(30);
			//var btn1:Sprite = new Sprite();
			//var btn2:Sprite = new Sprite();
			//var btn3:Sprite = new Sprite();
			 
			addChild(btn1);
			addChild(btn2);
			addChild(btn3);
			btn1.x=60;
			btn1.y=btn2.y=btn3.y=60;
			btn2.x=btn1.x+btn1.width+dur;
			btn3.x=btn2.x+btn2.width+dur;
			var myMatrix:Matrix = new Matrix();
			var dx:Number=20;
			var dy:Number=20;
			var sx:Number=1.3;
			var sy:Number=1.3;
			var rot:Number=Math.PI/6;
			var rect:Shape = Rect(-100,-75,200,150);
			addChild(rect);
			setChildIndex(rect,0);
			rect.x=stage.stageWidth/2;
			rect.y=230;
			btn1.addEventListener("click",do1);
			btn2.addEventListener("click",do2);
			btn3.addEventListener("click",do3);
			
			function do1(me:MouseEvent):void{
				myMatrix.translate(sx,dy);
				rect.transform.matrix=myMatrix;
			}
			function do2(me:MouseEvent):void{
				myMatrix.scale(sx,sy);
				rect.transform.matrix=myMatrix;
			}
			function do3(me:MouseEvent):void{
				myMatrix.rotate(rot);
				rect.transform.matrix=myMatrix;
			}
		}
		private function Rect(a:Number,b:Number,w:Number,h:Number):Shape{
			var s:Shape = new Shape();
			addChild(s);
			s.graphics.beginFill(0x0099ff);
			s.graphics.drawRect(a,b,w,h);
			s.graphics.endFill();
			return s;
		}
	}
}